package com.hspedu.generic;

import java.util.ArrayList;

/**
 * @author 谷其昊
 * @version 1.0
 * @date 2022/2/11
 * @time 16:14
 */
@SuppressWarnings({"all"})
public class Generic02 {
    public static void main(String[] args) {

        //使用传统的方法来解决
        //不指定泛型默认就是Object
        ArrayList<Dog> arrayList = new ArrayList();
        arrayList.add(new Dog("旺财", 10));
        arrayList.add(new Dog("发财", 1));
        arrayList.add(new Dog("小黄", 5));

        //arrayList.add(new Cat("tom",1));

        for (Dog dog : arrayList) {
            System.out.println(dog.getName()+" "+dog.getAge());
        }
    }
}


